home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT1-5 / FIRST.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  2.2 KB  |  67 lines

  1.  
  2. Page 60,132
  3. ;.sall
  4. ;
  5. ;                        Program   FIRST
  6. ;                        ═══════════════
  7. ;                           Chapter 1
  8. ;
  9. ;                    Voronezh, 20 September 91
  10. ;                    ─────────────────────────
  11. ;
  12. ;          This  is  a  sample  of  assembler  program.   It
  13. ;          represents a simplest calculator one can imagine.
  14. ;          This  calculator is designed so simple for better
  15. ;          understanding.  It can just only add two  numbers
  16. ;          and  result  can't  be greater than 255.  You can
  17. ;          use the executable module FIRST.EXE or  run  this
  18. ;          program  under  CodeView  debugger.  Probably you
  19. ;          can meet some  commands  which  seem  to  be  not
  20. ;          completely  clear  even if you are an experienced
  21. ;          user.  Don't worry about them.  All the  commands
  22. ;          will be explained in later chapters.
  23. ;
  24. ;
  25. .model SMALL                    ; This defines memory model
  26. ;.xlist                          ; On first pass
  27.     include maclib.inc      ;   open macro library
  28. ;.list
  29. ;
  30. ;═══════════════  C O D E   S E G M E N T   ═══════════════
  31. ;
  32. .code                           ; This starts the CODE segment
  33.                 ;
  34. Begin:                          ; This is the beginning
  35.                 ;   of program instructions
  36.                 ;
  37.     mov     bx,0            ; Clear BX register
  38.                 ;
  39.     InpInt  bx              ; Input the first operand
  40.                 ;
  41.     mov     cx,bx           ; Save it in CX register
  42.                 ;
  43.     InpInt  bx              ; Input the second operand
  44.                 ;
  45.     add     bl,cl           ; Add operands. Note: it is
  46.                 ;   a main command for this
  47.                 ;      program.
  48.                 ;
  49.     OutInt  bx              ; Put result on screen
  50.                 ;
  51. Finish:                         ; This starts the block that
  52.                 ;   ends the program
  53.                 ;
  54.     mov     ax,4C00h        ; AH contains the code 4Ch
  55.                 ;   This is a DOS function
  56.                 ;   number, AL register
  57.                 ;   contains return code 00.
  58.     int     21h             ; Dos service call
  59.  
  60. .data                           ; This starts the DATA segment
  61. .stack                          ; This starts the STACK segment
  62.                 ;
  63.     end     Begin           ; This is the end of the
  64.                 ;   program. The executing
  65.                 ;   will start from the
  66.                 ;   label "Begin".
  67.